package com.shop.loan.model;

import com.shop.loan.proxy.StatisticsByDayProxy;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.annotation.sub_field.sub_edit.VL;
import xyz.erupt.jpa.model.BaseModel;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import java.math.BigDecimal;
import java.util.Date;

@Setter
@Getter
@Entity
@Table(name = "s_statistics_day",
        uniqueConstraints = {
                @UniqueConstraint(columnNames = {"day", "type"})
        })
@Erupt(
        name = "每日账单统计",
        orderBy = "id desc",
        dataProxy = StatisticsByDayProxy.class,
        power = @Power(add = false, edit = false, viewDetails = false, delete = false)
)
public class StatisticsByDay extends BaseModel {

    @EruptField(
            views = @View(title = "日期",width = "150px"),
            edit = @Edit(title = "日期",
                    readonly = @Readonly,
                    search = @Search(vague = true),
                    dateType = @DateType(type = DateType.Type.DATE))
    )
    private Date day;


    @EruptField(
            views = @View(title = "新老客户",width = "100px"),
            edit = @Edit(
                    title = "新老客户",
                    type = EditType.CHOICE,
                    search = @Search(),
                    choiceType = @ChoiceType(
                            vl = {
                                    @VL(label = "全部", value = "1"),
                                    @VL(label = "新客户", value = "2"),
                                    @VL(label = "老客户", value = "3"),
                            }
                    ))
    )
    private Integer type;

//    @Transient
//    @EruptField(
//            edit = @Edit(
//                    title = "所属渠道",
//                    search = @Search(vague = true),
//                    type = EditType.REFERENCE_TREE
//            )
//    )
//    private Channel channel;


    @Transient
    @EruptField(
            views = @View(title = "应还订单数"),
            edit = @Edit(
                    title = "应还订单数"
            )
    )
    private Integer orderNum;


    @Transient
    @EruptField(
            views = @View(title = "结清订单数"),
            edit = @Edit(
                    title = "结清订单数"
            )
    )
    private Integer orderNumByEnd;


    @Transient
    @EruptField(
            views = @View(title = "已还订单数"),
            edit = @Edit(
                    title = "已还订单数"
            )
    )
    private Integer orderNumByPay;


    @Transient
    @EruptField(
            views = @View(title = "订单回款率(%)"),
            edit = @Edit(
                    title = "订单回款率(%)"
            )
    )
    private Integer orderRateByPay;


    @Transient
    @EruptField(
            views = @View(title = "应还金额"),
            edit = @Edit(
                    title = "应还金额"
            )
    )
    private Integer money;

    @Transient
    @EruptField(
            views = @View(title = "已还金额"),
            edit = @Edit(
                    title = "已还金额"
            )
    )
    private Integer payMoney;


    @Transient
    @EruptField(
            views = @View(title = "全额还款金额"),
            edit = @Edit(
                    title = "全额还款金额"
            )
    )
    private Integer payMoneyByAll;


    @Transient
    @EruptField(
            views = @View(title = "部分还款金额"),
            edit = @Edit(
                    title = "部分还款金额"
            )
    )
    private Integer payMoneyByPart;


    @Transient
    @EruptField(
            views = @View(title = "优惠本息"),
            edit = @Edit(
                    title = "优惠本息"
            )
    )
    private Integer discountMoney;

    @Transient
    @EruptField(
            views = @View(title = "金额回款率(%)", width = "120px"),
            edit = @Edit(
                    title = "金额回款率(%)"
            )
    )
    private BigDecimal payRate;

}
